
$(function () {
	var element = layui.element;
	element.render();

	var form = layui.form;
	form.render();

	tt.Conf.errorStyle = 'alert';
    tt.Conf.clearOtherError = true;
    
	//给加js验证
	tt.vf.req.addId('newpwd');

});



function setNewPwd(evt, form1) {
	if (!tt.validateForm('form1')) {   //loginForm是form的name  
		return false;
	}
	form1.authCode.value = getQueryString("authCode");
	var data = $(form1).serialize();
	ajax.post('/register/setNewPwd', {
		data: data,
		success: function (resp) {
			if (resp.ok) {
				// layer.alert(resp.msg);

				//自动登录
				var data = resp.data;
				var loginForm = document.forms["tiosite_loginForm"];
				loginForm.loginname.value = data.loginname;
				$('#tiosite_login_pwd_show').val(data.pwd);
				tiosite_login(loginForm, function(resp2) {
					location.href = "/doc";
				});
			} else {
				layer.alert(resp.msg);
			}
		}
	});
}